package sg.com.techstudio.tafep.obj;

import java.io.Serializable;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.apache.commons.lang3.StringUtils;

@Entity
@Table(name="registration" )
public class RegisterObj implements Serializable{
	private static final long serialVersionUID = 346464719150878903L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Long id;
	private Boolean pledger;
	private boolean receiveUpdate, snefMember, updateAddress;
	private String snefId;
	private String salutation, salutationOther, name, firstName, lastName
		, designation;
	private String areaCode="65", telephone, email;
	private String companyName, companyAddress, newAddress, postCode;
	@OneToMany(cascade= {CascadeType.ALL}, fetch=FetchType.EAGER)
	private List<ParticipantObj> participantList = new LinkedList<ParticipantObj>();
	private Date createdDate, updatedDate;
	private String payerEmail;
	private int paymentStatus, noParticipant, status;
	private Double amount;
	
	@OneToOne(cascade= {CascadeType.ALL}, orphanRemoval=true, fetch=FetchType.EAGER)
	private ChequeContact chequeContact;
	
	@Transient
	private Long companyId;
	
	private String companyNameOther;
	
	public int getStatus() {
		return status;
	}
	public void setStatus(int status) {
		this.status = status;
	}
	public void clearParticipant() {
		participantList.clear();
	}
	public boolean isOtherCompany() {
		return pledger!=null && pledger && StringUtils.isBlank(companyName);
	}
	
	public int getParticipantSize() {
		return participantList==null?0:participantList.size();
	}
	
	public String getCompanyNameOther() {
		return companyNameOther;
	}
	public String getPostCode() {
		return postCode;
	}
	public void setPostCode(String postCode) {
		this.postCode = postCode;
	}
	public String getNewAddress() {
		return newAddress;
	}
	public void setNewAddress(String newAddress) {
		this.newAddress = newAddress;
	}
	public String getAreaCode() {
		return areaCode;
	}
	public void setAreaCode(String areaCode) {
		this.areaCode = areaCode;
	}
	public int getNoParticipant() {
		return noParticipant;
	}
	public void setNoParticipant(int noParticipant) {
		this.noParticipant = noParticipant;
	}
	public void setCompanyNameOther(String companyNameOther) {
		this.companyNameOther = companyNameOther;
	}
	public boolean isUpdateAddress() {
		return updateAddress;
	}
	public void setUpdateAddress(boolean updateAddress) {
		this.updateAddress = updateAddress;
	}
	public Long getCompanyId() {
		return companyId;
	}
	public void setCompanyId(Long companyId) {
		this.companyId = companyId;
	}
	public ChequeContact getChequeContact() {
		return chequeContact;
	}
	public void setChequeContact(ChequeContact chequeContact) {
		this.chequeContact = chequeContact;
	}
	public Long getId() {
		return id;
	}
	public Double getAmount() {
		return amount;
	}
	public void setAmount(Double amount) {
		this.amount = amount;
	}
	public String getPayerEmail() {
		return payerEmail;
	}
	public void setPayerEmail(String payerEmail) {
		this.payerEmail = payerEmail;
	}
	public int getPaymentStatus() {
		return paymentStatus;
	}
	public void setPaymentStatus(int paymentStatus) {
		this.paymentStatus = paymentStatus;
	}
	public Date getCreatedDate() {
		return createdDate;
	}
	public void setCreatedDate(Date createdDate) {
		this.createdDate = createdDate;
	}
	public Date getUpdatedDate() {
		return updatedDate;
	}
	public void setUpdatedDate(Date updatedDate) {
		this.updatedDate = updatedDate;
	}
	public boolean isSnefMember() {
		return snefMember;
	}
	public void setSnefMember(boolean snefMember) {
		this.snefMember = snefMember;
	}
	public String getSnefId() {
		return snefId;
	}
	public void setSnefId(String snefId) {
		this.snefId = snefId;
	}
	public List<ParticipantObj> getParticipantList() {
		return participantList;
	}
	public void setParticipantList(List<ParticipantObj> participantList) {
		this.participantList = participantList;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public Boolean getPledger() {
		return pledger;
	}
	public void setPledger(Boolean pledger) {
		this.pledger = pledger;
	}
	public boolean isReceiveUpdate() {
		return receiveUpdate;
	}
	public void setReceiveUpdate(boolean receiveUpdate) {
		this.receiveUpdate = receiveUpdate;
	}
	public String getSalutation() {
		return salutation;
	}
	public void setSalutation(String salutation) {
		this.salutation = salutation;
	}
	public String getSalutationOther() {
		return salutationOther;
	}
	public void setSalutationOther(String salutationOther) {
		this.salutationOther = salutationOther;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getDesignation() {
		return designation;
	}
	public void setDesignation(String designation) {
		this.designation = designation;
	}
	public String getTelephone() {
		return telephone;
	}
	public void setTelephone(String telephone) {
		this.telephone = telephone;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	public String getCompanyName() {
		return companyName;
	}
	public void setCompanyName(String companyName) {
		this.companyName = companyName;
	}
	public String getCompanyAddress() {
		return companyAddress;
	}
	public void setCompanyAddress(String companyAddress) {
		this.companyAddress = companyAddress;
	}
	public String getFirstName() {
		return firstName;
	}
	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}
	public String getLastName() {
		return lastName;
	}
	public void setLastName(String lastName) {
		this.lastName = lastName;
	}
}
